| Conditions | 1 |
| Total Lines | 23 |
| Code Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 5 |
| CRAP Score | 1 |
| Changes | 0 | ||
| 1 | 12 | import * as turf from '@turf/turf'; |
|
| 8 | |||
| 9 | 12 | export function positionInsidePolygon( |
|
| 10 | lat: number, |
||
| 11 | lon: number, |
||
| 12 | polygon: { lat: number; lng: number }[], |
||
| 13 | ): boolean { |
||
| 14 | 486 | const point = { |
|
| 15 | type: 'Feature' as const, |
||
| 16 | properties: {}, |
||
| 17 | geometry: { |
||
| 18 | type: 'Point' as const, |
||
| 19 | coordinates: [lon, lat], |
||
| 20 | }, |
||
| 21 | }; |
||
| 22 | 486 | const poly = { |
|
| 23 | type: 'Feature' as const, |
||
| 24 | properties: {}, |
||
| 25 | geometry: { |
||
| 26 | type: 'Polygon' as const, |
||
| 27 | 2469 | coordinates: [polygon.map((p) => [p.lng, p.lat])], |
|
| 28 | }, |
||
| 29 | }; |
||
| 30 | 486 | return turf.booleanPointInPolygon(point, poly); |
|
| 31 | } |
||
| 32 |